package com.sunwayworld.basemodule.coredata.producttestinfo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.coredata.producttestinfo.dao.LimsProductTestInfoDao;
import com.sunwayworld.basemodule.coredata.producttestinfo.bean.LimsProductTestInfoBean;
import com.sunwayworld.basemodule.coredata.producttestinfo.service.LimsProductTestInfoService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsProductTestInfoServiceImpl implements LimsProductTestInfoService {

    @Autowired
    private LimsProductTestInfoDao limsProductTestInfoDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsProductTestInfoDao getDao() {
        return limsProductTestInfoDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsProductTestInfoBean limsProductTestInfo = jsonWrapper.parseUnique(LimsProductTestInfoBean.class);
        limsProductTestInfo.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsProductTestInfo);
        return limsProductTestInfo.getId();
    }

}
